package com.example.gramediamajalahmobile.channel;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageButton;

import com.example.gramediamajalahmobile.ChannelBean;
import com.example.gramediamajalahmobile.R;
import com.example.gramediamajalahmobile.sqlite.DBHelperChannel;

public class ChooseChannel extends Activity {

	ImageButton bhiburan, bpengetahuan, bkomunitas, bkecantikan, bfashion,
			bteen, bselingan;
	ImageButton bsepakbola, bbalap, botomotif, bteknologi, bkesehatan,
			bkeluarga, bdongeng, brumah;
	Button next ; 
	protected DBHelperChannel dbHelper;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.choosechannel);
		dbHelper = new DBHelperChannel(this);
		dbHelper.open();

		bhiburan = (ImageButton) findViewById(R.id.hiburan);
		bhiburan.setOnClickListener(buttonchannelclick);
		bpengetahuan = (ImageButton) findViewById(R.id.pengetahuan);
		bpengetahuan.setOnClickListener(buttonchannelclick);
		bkomunitas = (ImageButton) findViewById(R.id.komunitas);
		bkomunitas.setOnClickListener(buttonchannelclick);
		bkecantikan = (ImageButton) findViewById(R.id.kecantikan);
		bkecantikan.setOnClickListener(buttonchannelclick);
		bfashion = (ImageButton) findViewById(R.id.fashion);
		bfashion.setOnClickListener(buttonchannelclick);
		bteen = (ImageButton) findViewById(R.id.teen);
		bteen.setOnClickListener(buttonchannelclick);
		bselingan = (ImageButton) findViewById(R.id.selingan);
		bselingan.setOnClickListener(buttonchannelclick);
		bsepakbola = (ImageButton) findViewById(R.id.sepakbola);
		bsepakbola.setOnClickListener(buttonchannelclick);
		bbalap = (ImageButton) findViewById(R.id.balap);
		bbalap.setOnClickListener(buttonchannelclick);
		botomotif = (ImageButton) findViewById(R.id.otomatif);
		botomotif.setOnClickListener(buttonchannelclick);
		bteknologi = (ImageButton) findViewById(R.id.teknologi);
		bteknologi.setOnClickListener(buttonchannelclick);
		bkesehatan = (ImageButton) findViewById(R.id.kesehatan);
		bkesehatan.setOnClickListener(buttonchannelclick);
		bkeluarga = (ImageButton) findViewById(R.id.keluarga);
		bkeluarga.setOnClickListener(buttonchannelclick);
		bdongeng = (ImageButton) findViewById(R.id.dongeng);
		bdongeng.setOnClickListener(buttonchannelclick);
		brumah = (ImageButton) findViewById(R.id.rumah);
		brumah.setOnClickListener(buttonchannelclick);
		next = (Button) findViewById(R.id.next);

		next.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent in = new Intent(ChooseChannel.this, Channel.class);
				startActivity(in);
				dbHelper.close();
			}
		});

	}

	private OnClickListener buttonchannelclick = new OnClickListener() {

		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			switch (v.getId()) {
			case R.id.hiburan:
				ChannelBean channel1 = new ChannelBean();
				channel1.setNama("Hiburan");
				channel1.setChannel("75");
				channel1.setGambar(R.drawable.news);
				dbHelper.createChannel(channel1);
				
				bhiburan.setBackgroundColor(Color.GRAY);
				break;
			case R.id.pengetahuan:
				ChannelBean channel2 = new ChannelBean();
				channel2.setNama("Pengetahuan");
				channel2.setChannel("44");
				channel2.setGambar(R.drawable.pengetahuan);
				dbHelper.createChannel(channel2);
				bpengetahuan.setBackgroundColor(Color.GRAY);
		
				break ;
			case R.id.komunitas:
				ChannelBean channel3 = new ChannelBean();
				channel3.setNama("Komunitas");
				channel3.setChannel("47");
				channel3.setGambar(R.drawable.comunity);
				dbHelper.createChannel(channel3);
				break;
			case R.id.kecantikan:
				ChannelBean channel4 = new ChannelBean();
				channel4.setNama("Kecantikan");
				channel4.setChannel("26");
				channel4.setGambar(R.drawable.kecantikan);
				dbHelper.createChannel(channel4);
				break;
			case R.id.fashion:
				ChannelBean channel5 = new ChannelBean();
				channel5.setNama("Fashion");
				channel5.setChannel("27");
				channel5.setGambar(R.drawable.fashion);
				dbHelper.createChannel(channel5);
				break;
			case R.id.teen:
				ChannelBean channel6 = new ChannelBean();
				channel6.setNama("Teen");
				channel6.setChannel("4");
				channel6.setGambar(R.drawable.teen);
				dbHelper.createChannel(channel6);
				break;
			case R.id.selingan:
				ChannelBean channel7 = new ChannelBean();
				channel7.setNama("Selingan");
				channel7.setChannel("77");
				channel7.setGambar(R.drawable.news);
				dbHelper.createChannel(channel7);
				break;
			case R.id.sepakbola:
				ChannelBean channel8 = new ChannelBean();
				channel8.setNama("Sepakbola");
				channel8.setChannel("51");
				channel8.setGambar(R.drawable.bola);
				dbHelper.createChannel(channel8);
				break;
			case R.id.balap:
				ChannelBean channel9 = new ChannelBean();
				channel9.setNama("Balap");
				channel9.setChannel("55");
				channel9.setGambar(R.drawable.balap);
				dbHelper.createChannel(channel9);
				break;
			case R.id.otomatif:
				ChannelBean channel10 = new ChannelBean();
				channel10.setNama("Otomotif");
				channel10.setChannel("8");
				channel10.setGambar(R.drawable.otomotif);
				dbHelper.createChannel(channel10);
				break;
			case R.id.teknologi:
				ChannelBean channel11 = new ChannelBean();
				channel11.setNama("Teknologi");
				channel11.setChannel("6");
				channel11.setGambar(R.drawable.teknologi);
				dbHelper.createChannel(channel11);
				break;
			case R.id.kesehatan:
				ChannelBean channel12 = new ChannelBean();
				channel12.setNama("Kesehatan");
				channel12.setChannel("28");
				channel12.setGambar(R.drawable.kesehatan);
				dbHelper.createChannel(channel12);
				break;
			case R.id.keluarga:
				ChannelBean channel13 = new ChannelBean();
				channel13.setNama("Keluarga");
				channel13.setChannel("76");
				channel13.setGambar(R.drawable.keluarga);
				dbHelper.createChannel(channel13);
				break;
			case R.id.dongeng:
				ChannelBean channel14 = new ChannelBean();
				channel14.setNama("Dongeng");
				channel14.setChannel("35");
				channel14.setGambar(R.drawable.dongeng);
				dbHelper.createChannel(channel14);
				break;
			case R.id.rumah:
				ChannelBean channel15 = new ChannelBean();
				channel15.setNama("Rumah");
				channel15.setChannel("1");
				channel15.setGambar(R.drawable.rumah);
				dbHelper.createChannel(channel15);
				break;

			default:
				break;
			}
		}
	};

}
